{include file="public/header"}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <style scoped>
            .checkbox {
                cursor: pointer;
            }

            .checkmod {
                margin-bottom: 20px;
                border: 1px solid #ebebeb;
                padding-bottom: 5px;
            }

            .checkmod dt {
                padding-left: 10px;
                height: 30px;
                line-height: 30px;
                font-weight: bold;
                border-bottom: 1px solid #ebebeb;
                background-color: #ECECEC;
            }

            .checkmod dt {
                margin-bottom: 5px;
                border-bottom-color: #ebebeb;
                background-color: #ECECEC;
            }

            .checkbox, .radio {
                display: inline-block;
                height: 20px;
                line-height: 20px;
                margin-left: 20px;
            }

            .checkmod dd {
                padding-left: 30px;
                line-height: 30px;
            }

            .checkmod dd .checkbox {
                margin: 0 30px 0 0;
            }

            .checkmod dd .divsion {
                margin-right: 20px;
            }

            .checkmod dt {
                line-height: 30px;
                font-weight: bold;

            }

            .rule_check {
                border: 1px solid #ebebeb;
                margin: auto;
                padding: 5px 15px;
            }

            .menu_parent {
                margin-bottom: 5px;
            }
        </style>

        <div class="col-md-12">
            <div class="box box-primary">
                {include file="template/form_header" /}
                <div class="box-header with-border">
                    <h3 class="box-title">【{$role_name}】授权</h3>
                    <label class="checkbox" for="check_all">
                        <input class="checkbox-inline" type="checkbox" name="check_all" id="check_all">全选
                    </label>
                </div>
                <div class="box-body" id="all_check">
                    <form id="dataForm" class="form-horizontal dataForm" action="" method="post"
                          enctype="multipart/form-data">
                        <div class="box-body">
                            <div class="table_full">
                                <table width="100%" cellspacing="0">
                                    <tbody>
                                    {$html['html']}
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        {include file="template/form_footer" /}
                    </form>
                </div>
            </div>
        </div>

    </div>
</div>
{include file="public/footer"}
<script type="text/javascript">
    $("#check_all").click(function () {
        if (this.checked) {
            $("#all_check").find(":checkbox").prop("checked", true);
        } else {
            $("#all_check").find(":checkbox").prop("checked", false);
        }
    });

    function checknode(obj) {
        var level_bottom;
        var chk = $("input[type='checkbox']");
        var count = chk.length;
        var num = chk.index(obj);
        var level_top = level_bottom = chk.eq(num).attr('level');

        for (var i = num; i >= 0; i--) {
            var le = chk.eq(i).attr('level');
            if (eval(le) < eval(level_top)) {
                chk.eq(i).prop("checked", true);
                level_top = level_top - 1;
            }
        }

        for (var j = num + 1; j < count; j++) {
            le = chk.eq(j).attr('level');
            if (chk.eq(num).prop("checked")) {
                if (eval(le) > eval(level_bottom)) {

                    chk.eq(j).prop("checked", true);
                }
                else if (eval(le) == eval(level_bottom)) {
                    break;
                }
            } else {
                if (eval(le) > eval(level_bottom)) {
                    chk.eq(j).prop("checked", false);
                } else if (eval(le) == eval(level_bottom)) {
                    break;
                }
            }
        }

        var all_length = $("input[name='menu_id[]']").length;
        var checked_length = $("input[name='menu_id[]']:checked").length;
        console.log(all_length);
        console.log(checked_length);
        if (all_length == checked_length) {
            $("#check_all").prop("checked", true);
        } else {
            $("#check_all").prop("checked", false);
        }

    }
</script>
</html>